1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../'); |
3
|
|
|
|
4
|
|
|
describe('SourceCitation', function(){ |
5
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
7
|
|
|
assert.instanceOf(new GedcomX.SourceCitation(), GedcomX.SourceCitation, 'An instance of SourceCitation is not returned when calling the constructor with new.'); |
8
|
|
|
assert.instanceOf(GedcomX.SourceCitation(), GedcomX.SourceCitation, 'An instance of SourceCitation is not returned when calling the constructor without new.'); |
9
|
|
|
}); |
10
|
|
|
|
11
|
|
|
it('Create with JSON', function(){ |
12
|
|
|
var citation = GedcomX.SourceCitation({ |
13
|
|
|
lang: 'en', |
14
|
|
|
value: 'a full text citation' |
15
|
|
|
}); |
16
|
|
|
assert.equal(citation.getLang(), 'en'); |
17
|
|
|
assert.equal(citation.getValue(), 'a full text citation'); |
18
|
|
|
}); |
19
|
|
|
|
20
|
|
|
it('Build', function(){ |
21
|
|
|
var citation = GedcomX.SourceCitation() |
22
|
|
|
.setLang('en') |
23
|
|
|
.setValue('a full text citation'); |
24
|
|
|
assert.equal(citation.getLang(), 'en'); |
25
|
|
|
assert.equal(citation.getValue(), 'a full text citation'); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
it('toJSON', function(){ |
29
|
|
|
var data = { |
30
|
|
|
lang: 'en', |
31
|
|
|
value: 'a full text citation' |
32
|
|
|
}, citation = GedcomX.SourceCitation(data); |
33
|
|
|
assert.deepEqual(citation.toJSON(), data); |
34
|
|
|
}); |
35
|
|
|
|
36
|
|
|
it('constructor does not copy instances', function(){ |
37
|
|
|
var obj1 = GedcomX.SourceCitation(); |
38
|
|
|
var obj2 = GedcomX.SourceCitation(obj1); |
39
|
|
|
assert.strictEqual(obj1, obj2); |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
}); |